package com.czjtxy.extraTerm.controller.jobmodule;

import com.czjtxy.extraTerm.entity.DO.Tjob;
import com.czjtxy.extraTerm.server.JobService;
import com.czjtxy.extraTerm.serverImpl.JobServiceImpl;
import com.czjtxy.extraTerm.util.Util;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @program: staff-house
 * @author: MingYi
 * @create: 2021/07/02 19:47
 */
@WebServlet(name = "UpdateJobServlet", value = "/UpdateJobServlet")
public class UpdateJobServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Tjob tjob = new Tjob();
        tjob.setId(Util.stringToInt(req.getParameter("id")));
        tjob.setName(req.getParameter("name"));
        tjob.setRemark(req.getParameter("remark"));

        JobService jobService = new JobServiceImpl();
        try {
            jobService.updateJob(tjob);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        req.getRequestDispatcher("/JobServlet").forward(req, resp);
    }
}

